<?php
/**
 * Created by PhpStorm.
 * User: u
 * Date: 2019/4/8
 * Time: 14:58
 */

namespace common\sources\read\principalcash;


use Yii;
use common\models\craftsman\PrincipalCashRecord;

class PrincipalCashAccess implements IPrincipalCashAccess
{
     public function getPrincipalCashCount($data)
     {
         return PrincipalCashRecord::find()
                    ->where(['buy_id' => $data['buy_id']])
                    ->count();
     }

     public function getPrincipalCashList($data)
     {
         return PrincipalCashRecord::find()
                ->select("id,cash_num,money,cash_money,status,remark,task_order_ids,cash_money,reason,create_time")
                ->where(['buy_id' => $data['buy_id']])
                ->orderBy("id desc")
                ->offset(($data['page_num']-1) * $data['limit'])
                ->limit($data['limit'])
                ->asArray()
                ->all();
     }
     public function getPrincipalCashById($principal_cash_id)
     {
         return PrincipalCashRecord::find()
             ->select("id,cash_num,money,cash_money,status,remark,task_order_ids,create_time")
             ->where(['id' => $principal_cash_id])
             ->asArray()
             ->one();
     }
}